package com.iamgod.savemoney.utils;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

/**
 * @author lihui
 *
 */
public class DrawableUtil {
	
	/**
	 * 生成酒店覆盖物
	 * @param title
	 * @return
	 */
	public  static Drawable drawImage(String title){
		Bitmap bm = Bitmap.createBitmap(150, 100, Config.ARGB_8888);
		Canvas canvas = new Canvas(bm);
		 Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
		   paint.setColor(Color.BLUE);
		   //canvas.drawRect(new Rect(0,0,150,100), paint);
		   paint.setStyle(Paint.Style.STROKE);
		   canvas.drawRoundRect(new RectF(0,0,150,100), 10, 5, paint);
		   
		   paint.setColor(Color.DKGRAY);
		   canvas.drawCircle(30, 30, 30, paint);
		   paint.setColor(Color.RED);
		   paint.setTextSize(15);
		   canvas.drawText("生成带圆角的图片", 0, 20, paint);
		   
		canvas.save();
		canvas.restore();
		
		return new BitmapDrawable(bm); 
	}

}
